package Demo08.Demo0814;

public class Homework {
    public static void main(String[] args) {
        String str = "123456";
        int num1 = Integer.valueOf(str);
        int num2 = Integer.parseInt(str);
        System.out.println(num1);
        System.out.println(num2);
    }
    public static void main3(String[] args) {
        //int 转为 string
        int num = 10;
        //方法一：
        String str1 = num + "";
        System.out.println(str1);
        //方法二
        String str2 = String.valueOf(num);
        System.out.println(str2);
        //方法三
        String str3 = Integer.toString(num);
        String str4 = Integer.toBinaryString(num);//这里转换为二进制，toHexString是转换为八进制的，toOctal是转换为16进制的
        System.out.println(str3);
        System.out.println(str4);
    }


    public static void main2(String[] args) {
        int a = 100;
        int b = 100;
        double c = 100.00;
        //a = c;//不成功，这里是 double -->int ,大范围到小范围需要强制类型转化
        b = (int)b; //成功，这里是 double -->int ,大范围到小范围需要强制类型转化

        boolean flag = true;
        //a = flag; //类型不兼容
    }
    public static void main1(String[] args) {
        byte a = 100;
        byte b = 10;
        byte c = 100 + 10;
        byte d =(byte)( a + b);
    }
}
